﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginPage.ascx.cs" Inherits="LoginPage" %>

<%--客製參考--%>
<link href="Content/LoginPage.css" rel="stylesheet" />
<style>
    .logintxt {
        width:90%;
        display:inline-block;
        margin-left:10px;
    }
</style>
<%--客製參考--%>

<%--登入畫面--%>
<form id="formLogin"> 
    <div class="login-container cancel-login">
        <div class="login-content">
            <h4 id="test">會員登入</h4><%--test--%>
            <div class="social-login">
                <button id="oldUserLogin" type="button" class="btn btn-default1" style="background:#CB2027;color:#fff; "><span>Demo 老 U</span></button>               
                <button id="newUserLogin" type="button" class="btn btn-default1" style="background:#DD4B39;color:#fff; "><span>Demo 小 U</span></button>               
            </div>
            <div class="user-login">
                <div class="user-name">
                    <i class="glyphicon glyphicon-user"></i><input id="txtId"  class="form-control txt-name logintxt" placeholder="ID" autofocus/>
                </div>
                <div class="user-password">
                    <i class="glyphicon glyphicon-lock"></i><input type="password" id="txtPassword" class="form-control txt-password logintxt" placeholder="Password" />
                </div>
            </div>
            <div class="login-bottom">
                <div class="left-link">
                    <a id="lnkForgotPwd" class="login-link">忘記密碼?</a><br />
                    <a href="UserRegister.aspx" class="login-link">立即加入UBOX</a>
                </div>
                <div class="right-btn">
                    <button id="btnLogin" type="button" class="btn btn-danger">登入</button>
                    <button id="btnCancel" type="button" class="btn btn-default cancel-login">取消</button>
                </div>
            </div>
        </div>
        <div class="user-login forgot-pwd-content">
                <i class="glyphicon glyphicon-user"></i><input id="txtNameFg" class="form-control txt-name logintxt" placeholder="ID" />
                <i class="glyphicon glyphicon-envelope"></i><input id="txtEmailFg" class="form-control txt-password logintxt" type="email" placeholder="Email" />
            <div class="right-btn">
                <label>請輸入您的帳號和信箱</label>
                <img class="forgot-loading-img" src="images/icon-forgotLoading.gif" />
                <button id="btnForgotPwd" type="button" class="btn btn-danger">送出</button>
            </div>
        </div>
    </div>
</form>

<%--客製參考--%>
<script src="Scripts/LoginPage.js"></script>
<%--客製參考--%>

<%--<script src="../Scripts/jquery-2.1.1.min.js"></script>--%>
<script>
    $('#oldUserLogin').click(function () {
        $('#txtId').val('Ubox0001');
        $('#txtPassword').val('Ubox1234');
    });
    $('#newUserLogin').click(function () {
        $('#txtId').val('Ubox1000');
        $('#txtPassword').val('Ubox1234');
    });
    function checkUser() {
        var name = $('#txtId').val();
        var password = $('#txtPassword').val();
        $.post("Handler/HandlerUserLogin.ashx", { "status": "login", "name": name, "password": password },
        function (data) {
            switch (data) {
                case 'jailed':
                    uboxWarning('你的帳號目前被封鎖');
                    break;
                case 'null':
                    uboxLoginWarning('錯誤的帳號或密碼');
                    break;
                default:
                    if (data.Picture != null) {
                        $('#cboUserImg').attr('src', 'data:image/jpg;base64,' + data.Picture).unbind('click');
                    }
                    $("#cmdToolBarLogin").html(data.Name).unbind('click')
                    $('#cboUpload').unbind('click')
                    //$.cookie('u_id', data.ID);
                    loginOk();
                    fadeLoginContainer();
                    break;
                    }
                   
            })

        }

    $('#txtId, #txtPassword').keypress(function (e) {
        if (e.which == 13) {
            checkUser();
        }
    });
    $('#btnLogin').click(checkUser);

    function getPwd() {
        var name = $('#txtNameFg').val();
        var email = $('#txtEmailFg').val();
        var btn = $('#btnForgotPwd');
        var img = $('.forgot-loading-img');
        btn.prop("disabled", true);
        img.show();
        $.post("Handler/HandlerUserLogin.ashx", { "status": "getPwd", "name": name, "email": email },
        function (data) {
            switch (data) {
                case 'success':
                    uboxLoginWarning('請至信箱收取密碼提示');
                    btn.prop("disabled", false);
                    img.hide();
                    fadeLoginContainer();
                    break;
                default:
                    uboxLoginWarning('帳號或密碼不符,發送失敗!!');
                    btn.prop("disabled", false);
                    img.hide();
                    break;
            }
        })
    }

    $('#btnForgotPwd').click(getPwd);
</script>